package student;

import SQL.Score;

import java.sql.SQLException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author: 保护小周
 * Date: 2022-11-16
 * Time: 16:48
 */
public class ScoreFunction {
    private static void menu() {
        System.out.println();
        System.out.println("--------------学生成绩界面--------------");
        System.out.println("**************************************");
        System.out.println("***** 1.学生成绩表    2.增加学生成绩 *****");
        System.out.println("***** 3.删除学生成绩  4.查找学生成绩 *****");
        System.out.println("***** 5.修改学生成绩  0-退出此界面   *****");
        System.out.println("**************************************");
    }

    public static void function() throws SQLException, ClassNotFoundException {
        Scanner in = new Scanner(System.in);
        boolean flag = true;
        // IFunc[] func = { new Exit(), new Add(), new Show() };

        while( flag ) {
            menu(); //菜单
            System.out.println("请选择要执行的操作：");
            int size = in.nextInt();
            //func[size].work();
            switch ( size ) {
                case 1:
                    Score.show(); //显示成绩表
                    break;
                case 2:
                    Score.addScore(); //添加成绩
                    break;
                case 3:
                    Score.delScore(); //删除成绩
                    break;
                case 4:
                    System.out.println("请输入要查找的学生 ID:"); //查找学生成绩
                    String id =  in.nextLine();
                    Score.findStuScore(id);
                    break;
                case 5:
                    Score.modify(); //修改成绩
                    break;
                case 0: flag = false;
                    break;
                default:
                    System.out.println("输入错误！");
            }
        }
    }
}
